<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title></title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width">

        <style>
          thead th {
            text-align: left;
            border-bottom: 1px solid #000;
          }
          th, td {
            padding: 0.5em 1em 0 1em;
            font-family: 'Courier New', Courier, monospace;
          }
        </style>

        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
        <script>
          var generateDocsRow = function(x) {
            var html = '<tr><td>' + x + '</td>';
            html += '<td><a href="branches/' + x + '">Docs</a></td>';
            html += '<td><a href="branches/' + x + '/openapi.yaml">OpenAPI spec</a></td></tr>';

            return html;
          };

          $(function() {
            $.getJSON(
              'branches.json',
              function(data) {
                var list = $('#version-list');
                var html = '<thead><th>Version</th><th></th><th></th></thead><tbody>';

                html += generateDocsRow('latest');

                data.forEach(function(x) {
                  if (x != 'latest') {
                    html += generateDocsRow(x);
                  }
                });

                html += '</tbody>'

                list.append(html);
                $('#loading').hide();
              },
              function(err) {
                console.log(err);
              }
            );
          });
        </script>
    </head>
    <body>
        <!--[if lt IE 7]>
            <p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
        <![endif]-->

        <h2>MiLight Hub REST API Documentation</h2>

        <hr />

        <table id="version-list"></table>
        <i id="loading">Loading...</i>
    </body>
</html>